function maxSubArray(nums: number[]): number {
  let maxNum: number = nums[0];
  for (let i = 0; i < nums.length; i++) {
    let num: number = 0;
    for (let j = i; j < nums.length; j++) {
      num += nums[j];
      if (num > maxNum) {
        maxNum = num;
      }
    }
  }
  return maxNum;
}
console.log(maxSubArray([-2, 1, -3, 4, -1, 2, 1, -5, 4]));
